import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';

@Injectable()
export class LoggerMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: NextFunction) {
    // 日志中间件
    // 每次接收到请求, 就把相关的信息打印出来
    console.log(`[${new Date().toLocaleString()}] - ${req.method}:${req.url}`);

    next();
  }
}
